package com.tianlan.blog.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.tianlan.blog.vo.AuthVo;

import io.swagger.annotations.ApiModelProperty;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author tl-wxq
 * @since 2020-01-20
 */
@Entity
@Table(name ="sys_user")
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@SQLDelete(sql = "update sys_user set del_flag = 1 where id = ?")
@Where(clause = "del_flag = 0")
public class SysUser{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
   
    @Column(name = "user_account")
    private String userAccount;
    
    @Column(name = "user_nick_name")
    private String userNickName;
    
    @Column(name = "user_name")
    private String userName;
    
    @Column(name = "user_mobile")
    private String userMobile;
    
    @Column(name = "user_email")
    private String userEmail;
       
    @Column(name = "user_password")
	private String userPassword;
    
    private String salt;
              
    @ApiModelProperty(value = "1 : 男，0 : 女")
    @Column(name = "user_sex")
    private String userSex;
    
    @ApiModelProperty(value = "'0'禁用,'1' 启用, '2' 密码过期或初次未修改")
    @Column(name = "user_status")
    private String userStatus;
        
    @Column(name = "head_img_url")
    private String headImgUrl;

    @ApiModelProperty(value = "省")
    @Column(name = "province")
    private String province;

    @ApiModelProperty(value = "市")
    @Column(name = "city")
    private String city;

    @ApiModelProperty(value = "区")
    @Column(name = "area")
    private String area;
        
	@ApiModelProperty(value = "街道详细地址")
    @Column(name = "street")
    private String street;

    @ApiModelProperty(value = "备注")
    @Column(name = "description")
    private String description;

    @ApiModelProperty(value = "创建时间")
    @Column(name = "create_time")
    @CreatedDate
    private Date createTime;
    
    @ApiModelProperty(value = "创建者")
    @Column(name = "creator")
    @CreatedBy
    private Integer creator;

    @ApiModelProperty(value = "更新日期")
    @Column(name = "update_time")
    @LastModifiedDate
    private Date updateTime;

    @ApiModelProperty(value = "更新者")
    @Column(name = "operator")
    @LastModifiedBy
    private Integer operator;

    @ApiModelProperty(value = "1:删除 0:不删除")   
    @Column(name = "del_flag")
    private String delFlag;
    
    private Date birthday;
            
    private int version;
    
    @Transient
    private List<SysRole> roleList = new ArrayList<>();    //用户所有角色值，在管理后台显示用户的角色
    @Transient
    private Set<AuthVo> roles = new HashSet<>();    //用户所有角色值，用于shiro做角色权限的判断
    @Transient
    private Set<AuthVo> perms = new HashSet<>();    //用户所有权限值，用于shiro做资源权限的判断
    
//    @OneToMany(mappedBy = "sysUser",fetch=FetchType.EAGER, cascade = CascadeType.ALL)
//    private Set<SysUserRole> sysUserRole = new HashSet<>();
//    
//    @OneToMany(mappedBy = "sysUser",fetch=FetchType.EAGER, cascade = CascadeType.ALL)
//    private Set<SysDistrict> sysDistrict = new HashSet<>();
//    
//    @OneToMany(mappedBy = "sysUserCity",fetch=FetchType.EAGER, cascade = CascadeType.ALL)
//    private Set<SysDistrict> sysDistrictCity = new HashSet<>();
//    
//    @OneToMany(mappedBy = "sysUser",fetch=FetchType.EAGER, cascade = CascadeType.ALL)
//    private Set<SysOrganizationUser> sysOrganizationUser = new HashSet<>();
//    
//    @OneToMany(mappedBy = "sysUser",fetch=FetchType.EAGER, cascade = CascadeType.ALL)
//    private Set<SysOrganization> sysOrganization = new HashSet<>();
     
	public String getUserMobile() {
		return userMobile;
	}


	public void setUserMobile(String userMobile) {
		this.userMobile = userMobile;
	}


	public String getUserNickName() {
		return userNickName;
	}


	public void setUserNickName(String userNickName) {
		this.userNickName = userNickName;
	}


	public String getUserName() {
		return userName;
	}


	public void setUserName(String userName) {
		this.userName = userName;
	}
	
    public String getHeadImgUrl() {
		return headImgUrl;
	}


	public void setHeadImgUrl(String headImgUrl) {
		this.headImgUrl = headImgUrl;
	}


	public String getProvince() {
		return province;
	}


	public void setProvince(String province) {
		this.province = province;
	}


	public String getCity() {
		return city;
	}


	public void setCity(String city) {
		this.city = city;
	}


	public String getArea() {
		return area;
	}


	public void setArea(String area) {
		this.area = area;
	}


	public String getStreet() {
		return street;
	}


	public void setStreet(String street) {
		this.street = street;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}


	public Integer getCreator() {
		return creator;
	}


	public void setCreator(Integer creator) {
		this.creator = creator;
	}


	public Date getUpdateTime() {
		return updateTime;
	}


	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}


	public Integer getOperator() {
		return operator;
	}


	public void setOperator(Integer operator) {
		this.operator = operator;
	}


	public String getDelFlag() {
		return delFlag;
	}


	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}
    
   

	public List<SysRole> getRoleList() {
		return roleList;
	}


	public void setRoleList(List<SysRole> roleList) {
		this.roleList = roleList;
	}


	public Set<AuthVo> getRoles() {
		return roles;
	}


	public void setRoles(Set<AuthVo> roles) {
		this.roles = roles;
	}


	public Set<AuthVo> getPerms() {
		return perms;
	}


	public void setPerms(Set<AuthVo> perms) {
		this.perms = perms;
	}


	public Integer getId() {
		return id;
	}


	public void setId(Integer id) {
		this.id = id;
	}


	public String getuseAccount() {
		return userAccount;
	}

    public String getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(String userAccount) {
        this.userAccount = userAccount;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}


	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

	public String getUserEmail() {
		return userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

    public String getUserStatus() {
        return userStatus;
    }

    public void setUserStatus(String userStatus) {
        this.userStatus = userStatus;
    }

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}
  
}
